import axios from '@/request'
import { queryParams } from '@/utils'

export function getGoodsListApi(page, query = {}) {
  let r = queryParams(query)
  return axios.get(`/admin/goods/${page}${r}`)
}

// 批量上架/下架
export function updateGoodsStatusApi(ids, status) {
  return axios.post(`/admin/goods/changestatus`, {
    ids,
    status,
  })
}

export function createGoodsApi(data) {
  return axios.post(`/admin/goods`, data)
}

export function updateGoodsApi(id, data) {
  return axios.post(`/admin/goods/${id}`, data)
}

export function deleteGoodsApi(ids) {
  return axios.post(`/admin/goods/delete_all`, {
    ids,
  })
}

export function restoreGoodsApi(ids) {
  return axios.post(`/admin/goods/restore`, {
    ids,
  })
}

export function destroyGoodsApi(ids) {
  return axios.post(`/admin/goods/destroy`, {
    ids,
  })
}

export function readGoodsApi(id) {
  return axios.get(`/admin/goods/read/${id}`)
}

export function setGoodsBannerApi(id, data) {
  return axios.post(`/admin/goods/banners/${id}`, data)
}

export function updateGoodsSkusApi(id, data) {
  return axios.post(`/admin/goods/updateskus/${id}`, data)
}

export function createGoodsSkusCardApi(data) {
  return axios.post(`/admin/goods_skus_card`, data)
}

export function updateGoodsSkusCardApi(id, data) {
  return axios.post(`/admin/goods_skus_card/${id}`, data)
}

export function deleteGoodsSkusCardApi(id) {
  return axios.post(`/admin/goods_skus_card/${id}/delete`)
}

export function sortGoodsSkusCardApi(data) {
  return axios.post(`/admin/goods_skus_card/sort`, data)
}

export function createGoodsSkusCardValueApi(data) {
  return axios.post(`/admin/goods_skus_card_value`, data)
}

export function updateGoodsSkusCardValueApi(id, data) {
  return axios.post(`/admin/goods_skus_card_value/${id}`, data)
}

export function deleteGoodsSkusCardValueApi(id) {
  return axios.post(`/admin/goods_skus_card_value/${id}/delete`)
}

export function chooseAndSetGoodsSkusCardApi(id, data) {
  return axios.post(`/admin/goods_skus_card/${id}/set`, data)
}
